package com.example.controller;

import com.example.mapper.CurriculumVitaeMapper;
import com.example.service.CurriculumVitaeService;
import com.example.util.ImgUtils;
import com.example.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * 本文来演示
 *
 * @author 赵建云
 * @create 2023/10/8
 */
@RestController
@RequestMapping("curriculum")
public class CurriculumVitaeController {
    @Autowired
    private ImgUtils imgUtils;
    @Autowired
    private CurriculumVitaeService curriculumVitaeService;
    @PostMapping("file")
    public Result curriculum(MultipartFile[] file){
        if(ObjectUtils.isEmpty(file)){
            return new Result(500,"请选择上传的文件!");
        }
        Map<String, List<String>> uploadImagesUrl = imgUtils.uploadImages(file);
        return new Result(200,"上传成功",uploadImagesUrl);
    }

    @PostMapping("userGood")
    public Result saveUserGood(Integer jsId,String userGood){
        System.out.println(jsId+":"+userGood);
        int count = curriculumVitaeService.userGood(jsId,userGood);
        if (count==1){
            return new Result(200,"保存个人优点成功");
        }else {
            return new Result(500,"保存个人优点失败");
        }

    }


    //gxf
}
